<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">

    // Load the Visualization API and the piechart package.
    google.load('visualization', '1.0', {'packages': ['corechart']});

    // Set a callback to run when the Google Visualization API is loaded.
    google.setOnLoadCallback(drawChart);

    // Callback that creates and populates a data table,
    // instantiates the pie chart, passes in the data and
    // draws it.
    function drawChart() {

        // Create the data table.
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Date');
        data.addColumn('number', 'Visits');
        data.addColumn('number', 'Pageviews');
        data.addRows([
<?php
$i = 0;
foreach ($viewsbyday as $ss) {
    ?>
    <?php if ($i++) echo "," ?>['<?php
    $date = $ss->getDate();
    $year = substr($date, 0, 4);
    $month = substr($date, 4, 2);
    $day = substr($date, -2);
    echo $day;
    ?>', <?php echo $ss->getVisits() ?>,<?php echo $ss->getPageviews() ?>]
<?php } ?>

        ]);
                // Set chart options
                var options = {'title': 'Pageview & Visitors from <?php echo date('d-m-Y', time() - 3600 * 24 * 15) ?> to <?php echo date('d-m-Y', time()) ?>',
            'width': 950,
            'height': 300};

        // Instantiate and draw our chart, passing in some options.
        var chart = new google.visualization.ColumnChart(document.getElementById('dashboard_day_visitorscahrt'));
        chart.draw(data, options);

        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Country');
        data.addColumn('number', 'Pageviews');
        data.addRows([
<?php
$i = 0;
foreach ($viewsbycountry as $ss) {
    ?>
    <?php if ($i++) echo "," ?>['<?php echo $ss->getCountry() ?>', <?php echo $ss->getVisits() ?>]
<?php } ?>

        ]);
                // Set chart options
                var options = {'title': 'Visits by Countries',
            'width': 350,
            'height': 300};

        // Instantiate and draw our chart, passing in some options.
        var chart = new google.visualization.PieChart(document.getElementById('dashboard_cahrt'));
        chart.draw(data, options);
        
                var data = new google.visualization.DataTable();
        data.addColumn('string', 'Country');
        data.addColumn('number', 'Pageviews');
        data.addRows([
<?php
$i = 0;
foreach ($visitorsbycountry as $ss) {
    ?>
    <?php if ($i++) echo "," ?>['<?php echo $ss->getCountry() ?>', <?php echo $ss->getVisitors() ?>]
<?php } ?>

        ]);
                // Set chart options
                var options = {'title': 'Visitors by Countries',
            'width': 350,
            'height': 300};

        // Instantiate and draw our chart, passing in some options.
        var chart = new google.visualization.PieChart(document.getElementById('dashboard_cahrt_visitors'));
        chart.draw(data, options);
    }

</script>
<div class="shortcut-group">
    <ul class="a-btn-group">
        <li>
            <a href="<?= base_url() . ADMIN_FOLDER ?>/options" class="a-btn grd-white" rel="tooltip" title="<?= lang('label_menu_link_options') ?>">
                <span></span>
                <span><i class="icofont-cogs color-silver-dark"></i></span>
                <span class="color-silver-dark"><i class="icofont-cogs color-red"></i></span>
            </a>
        </li>
        <li>
            <a href="<?= base_url() . ADMIN_FOLDER ?>/users" class="a-btn grd-white" rel="tooltip" title="<?= lang('label_menu_link_users') ?>">
                <span></span>
                <span><i class="icofont-user color-silver-dark"></i></span>
                <span class="color-silver-dark"><i class="icofont-user color-green"></i></span>
            </a>
        </li>
        <li>
            <a href="<?= base_url() . ADMIN_FOLDER ?>/stores" class="a-btn grd-white" rel="tooltip" title="<?= lang('label_menu_link_stores') ?>">
                <span></span>
                <span><i class="icofont-shopping-cart color-silver-dark"></i></span>
                <span class="color-silver-dark"><i class="icofont-shopping-cart color-orange"></i></span>
                <div class="badge badge-info"></div> <!--don't use span here!-->
            </a>
        </li>
        <li>
            <a href="<?= base_url() . ADMIN_FOLDER ?>/invoicies" class="a-btn grd-white" rel="tooltip" title="<?= lang('label_menu_link_invoicies') ?>">
                <span></span>
                <span><i class="icofont-list color-silver-dark"></i></span>
                <span class="color-silver-dark"><i class="icofont-list-ul color-sky"></i></span>
                <div class="label label-important"></div> <!--don't use span here!-->
            </a>
        </li>
        <li>
            <a href="<?= base_url() . ADMIN_FOLDER ?>/advertise" class="a-btn grd-white" rel="tooltip" title="<?= lang('label_menu_link_advertise') ?>">
                <span></span>
                <span><i class="icofont-credit-card color-silver-dark"></i></span>
                <span class="color-silver-dark"><i class="icofont-credit-card color-purple"></i></span>
            </a>
        </li>
        <li>
            <a href="<?= base_url() . ADMIN_FOLDER ?>/sms_system" class="a-btn grd-white" rel="tooltip" title="<?= lang('label_menu_link_sms_system') ?>">
                <span></span>
                <span><i class="icofont-phone-sign color-silver-dark"></i></span>
                <span class="color-silver-dark"><i class="icofont-phone-sign color-blue"></i></span>
            </a>
        </li>
        <li>
            <a href="<?= base_url() . ADMIN_FOLDER ?>/shiping" class="a-btn grd-white" rel="tooltip" title="<?= lang('label_menu_link_shiping') ?>">
                <span></span>
                <span><i class="icofont-truck color-silver-dark"></i></span>
                <span class="color-silver-dark"><i class="icofont-truck color-purple-dark"></i></span>
            </a>
        </li>
        <li>
            <a href="<?= base_url() . ADMIN_FOLDER ?>/spages" class="a-btn grd-white" rel="tooltip" title="<?= lang('label_menu_link_spages') ?>">
                <span></span>
                <span><i class="icofont-file color-silver-dark"></i></span>
                <span class="color-silver-dark"><i class="icofont-dashboard color-teal"></i></span>
            </a>
        </li>
        <li class="clearfix"></li>
    </ul>
</div>


<div class="row-fluid" class="span5">
    <div class="span12" style="margin-left: 10px;">
        <div class="box">
            <div class="tab-header">
                <?= lang('status_visitors_pages') ?>
            </div>
            <div class="padded">
                <div id="dashboard_day_visitorscahrt" ></div>
            </div>
        </div>
    </div>
</div>



<div class="row-fluid" class="span5">
    <div class="span4" style="margin-left: 25px;">
        <div class="box">
            <div class="tab-header">
                <?= lang('status_countries_visits') ?>
            </div>
            <div class="padded">
                <div id="dashboard_cahrt" ></div>
            </div>
        </div>
    </div>
    
    <div class="row-fluid" class="span5">
    <div class="span4" style="margin-left: 25px;">
        <div class="box">
            <div class="tab-header">
                <?= lang('status_countries_visitors') ?>
            </div>
            <div class="padded">
                <div id="dashboard_cahrt_visitors" ></div>
            </div>
        </div>
    </div>

    <div class="span2" style="margin-left: 25px;" >
        <div class="box">
            <div class="tab-header">
                <?= lang('status_total_visits') ?>
            </div>
            <div class="padded">
                <div id="usrs_dashboard_cahrt" style="font-size: 50px; display: block; line-height: 115px; padding: 0px 25%;"><?= (isset($totalvisits)) ? $totalvisits : '0' ?></div>
            </div>
        </div>
        <div class="box">
            <div class="tab-header">
                <?= lang('status_total_visitors') ?>
            </div>
            <div class="padded">
                <div id="usrs_dashboard_cahrt" style="font-size: 50px; display: block; line-height: 115px; padding: 0px 25%;"><?= (isset($totalvisitors)) ? $totalvisitors : '0' ?></div>
            </div>
        </div>
    </div>
    
    <div class="span2" style="margin-left: 25px;" >
        <div class="box">
            <div class="tab-header">
                <h4 style="float: right; margin-left: 7px; line-height: 0"><?= lang('label_menu_link_stores').': ' ?></h4><?= (isset($all_stores)) ? '('.$all_stores.')' : '(0)'; ?>
            </div>
            <div class="padded">
                <div id="usrs_dashboard_cahrt"><strong><?= lang('label_menu_link_trash').': ' ?></strong><?= (isset($trash_stores)) ? '('.$trash_stores.')' : '(0)'; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_active').': ' ?></strong><?= (isset($active_stores)) ?'('.$active_stores.')' : '(0)'; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_deactive').': ' ?></strong><?= (isset($notactive_stores)) ? '('.$notactive_stores.')' : '(0)'; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_stores_notcompleted').': ' ?></strong><?= (isset($notcompleted_stores)) ? '('.$notcompleted_stores.')' : '(0)'; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_stores_topsub').': ' ?></strong><?= (isset($topsub_stores) && $topsub_stores) ? $topsub_stores : ' - '; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_stores_toplike').': ' ?></strong><?= (isset($toplike_stores) && $toplike_stores) ? "($likes %): ".$toplike_stores : ' - '; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_stores_bottomlike').': ' ?></strong><?= (isset($bottomlike_stores) && $bottomlike_stores) ? "($dislikes %): ".$bottomlike_stores : ' - '; ?></div>
            </div>
        </div>
    </div>
        <div class="span2" style="margin-left: 25px;" >
        <div class="box">
            <div class="tab-header">
                <h4 style="float: right; margin-left: 7px; line-height: 0"><?= lang('label_menu_link_invoicies').': ' ?></h4><?= (isset($all_invoices)) ? '('.$all_invoices.')' : '(0)'; ?>
            </div>
            <div class="padded">
                <div id="usrs_dashboard_cahrt"><strong><?= lang('label_menu_link_trash').': ' ?></strong><?= (isset($trash_invoices)) ? '('.$trash_invoices.')' : '(0)'; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_user_cancel').': ' ?></strong><?= (isset($user_cancel_invoices)) ?'('.$user_cancel_invoices.')' : '(0)'; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_admin_cancel').': ' ?></strong><?= (isset($admin_cancel_invoices)) ? '('.$admin_cancel_invoices.')' : '(0)'; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_invoices_create_store').': ' ?></strong><?= (isset($create_store_invoices)) ? '('.$create_store_invoices.')' : '(0)'; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_invoices_buyproduct').': ' ?></strong><?= (isset($buyproduct_invoices)) ? '('.$buyproduct_invoices.')' : ' (0) '; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_invoices_special_product').': ' ?></strong><?= (isset($special_product_invoices)) ? '('.$special_product_invoices.')' : ' (0) '; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_invoices_upgrade_store').': ' ?></strong><?= (isset($upgrade_store_invoices)) ? '('.$upgrade_store_invoices.')' : ' (0) '; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_invoices_active').': ' ?></strong><?= (isset($active_invoices)) ? "($active_invoices)" : ' (0) '; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_invoices_payment').': ' ?></strong><?= (isset($payment_invoices)) ? "($payment_invoices)" : ' (0) '; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_invoices_payment_active').': ' ?></strong><?= (isset($payment_active_invoices)) ? "($payment_active_invoices)" : ' (0) '; ?></div>
                
            </div>
        </div>
    </div>
    <div class="span3" style="margin-left: 25px;" >
        <div class="box">
            <div class="tab-header">
                <h4 style="float: right; margin-left: 7px; line-height: 0"><?= lang('label_menu_link_products').': ' ?></h4><?= (isset($all_products)) ? '('.$all_products.')' : '(0)'; ?>
            </div>
            <div class="padded">
                <div id="usrs_dashboard_cahrt"><strong><?= lang('label_menu_link_trash').': ' ?></strong><?= (isset($trash_products)) ? '('.$trash_products.')' : '(0)'; ?></div>
                <?php if(FALSE){ ?><div id="usrs_dashboard_cahrt"><strong><?= lang('status_active').': ' ?></strong><?= (isset($active_products)) ?'('.$active_products.')' : '(0)'; ?></div><?php } ?>
                <?php if(FALSE){ ?><div id="usrs_dashboard_cahrt"><strong><?= lang('status_deactive').': ' ?></strong><?= (isset($notactive_products)) ? '('.$notactive_products.')' : '(0)'; ?></div><?php } ?>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_products_special').': ' ?></strong><?= (isset($special_products)) ? '('.$special_products.')' : '(0)'; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_products_topbuy').': ' ?></strong><?= (isset($topbuy_products) && $topbuy_products) ? "($topbuy_products_max): ".$topbuy_products : ' - '; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_products_bottombuy').': ' ?></strong><?= (isset($bottombuy_products) && $bottombuy_products) ? "($bottombuy_products_max): ".$bottombuy_products : ' - '; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_products_toprice').': ' ?></strong><?= (isset($topprice_products) && $topprice_products) ? "($topprice_products_price): ".$topprice_products : ' - '; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_products_bottomprice').': ' ?></strong><?= (isset($bottomprice_products) && $bottomprice_products) ? "($bottomprice_products_price): ".$bottomprice_products : ' - '; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_products_topdiscount').': ' ?></strong><?= (isset($topdiscount_products) && $topdiscount_products) ? "($topdiscount_products_price %): ".$topdiscount_products : ' - '; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_products_bottomdiscount').': ' ?></strong><?= (isset($bottomdiscount_products) && $bottomdiscount_products) ? "($bottomdiscount_products_price %): ".$bottomdiscount_products : ' - '; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_products_topview').': ' ?></strong><?= (isset($topview_products)) ? "($topview): ".$topview_products : ' - '; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_products_bottomview').': ' ?></strong><?= (isset($bottomview_products)) ? "($bottomview): ".$bottomview_products : ' - '; ?></div>
                
            </div>
        </div>
    </div>
        <div class="span3" style="margin-left: 25px;" >
        <div class="box">
            <div class="tab-header">
                <h4 style="float: right; margin-left: 7px; line-height: 0"><?= lang('label_menu_link_users').': ' ?></h4><?= (isset($all_users)) ? '('.$all_users.')' : '(0)'; ?>
            </div>
            <div class="padded">
                <div id="usrs_dashboard_cahrt"><strong><?= lang('label_menu_link_trash').': ' ?></strong><?= (isset($trash_users)) ? '('.$trash_users.')' : '(0)'; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_users_user').': ' ?></strong><?= (isset($user_users)) ?'('.$user_users.')' : '(0)'; ?></div>
                <div id="usrs_dashboard_cahrt"><strong><?= lang('status_users_admin').': ' ?></strong><?= (isset($admin_users)) ? '('.$admin_users.')' : '(0)'; ?></div>
                
            </div>
        </div>
    </div>
</div>


